package core.bmp;

import core.bmp.model.BmpData;

public abstract class AbsMatrixPixWorker extends AbsWorker {

	/* 继承 */

	@Override
	protected final void onWork(BmpData bmpData) {
		int width = bmpData.getWidth();
		int height = bmpData.getHeight();

		int[] oneDimenArgbs = bmpData.getArgbPix();
		int[][] twoDimenArgbs = new int[height][width];

		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				twoDimenArgbs[i][j] = oneDimenArgbs[i * width + j];
			}
		}

		twoDimenArgbs = work(twoDimenArgbs);

		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				oneDimenArgbs[i * width + j] = twoDimenArgbs[i][j];
			}
		}
	}

	/* 内部回调 */

	protected abstract int[][] work(int[][] argbs);
}
